package com.example.secondhandsysapi.Service;

import com.example.secondhandsysapi.Entity.OrderInfo;
import com.example.secondhandsysapi.Mapper.OrderInfoMapper;
import com.example.secondhandsysapi.Vo.AwaitingShipment;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;

@Service
public class OrderInfoServiceImpl implements OrderInfoService {

    @Autowired
    private OrderInfoMapper orderInfoMapper;

    @Override
    public List<OrderInfo> getOrderInfo() {
        return orderInfoMapper.getOrderInfo();
    }

    @Override
    public List<OrderInfo> getOrderInfoByDate(String date) {
        return orderInfoMapper.getOrderInfoByDate(date);
    }

    @Override
    public List<OrderInfo> getOrderInfoByState(String state) {
        return orderInfoMapper.getOrderInfoByState(state);
    }

    @Override
    public List<OrderInfo> getOrderInfoByDateAndState(String date,String state) {
        return orderInfoMapper.getOrderInfoByDateAndState(date, state);

    }

    @Override
    public PageInfo<OrderInfo> getOrderPageInfo(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<OrderInfo> allOrderInfo = orderInfoMapper.getOrderInfoByDateAndState("","");
        PageInfo<OrderInfo> pageInfo = new PageInfo<>(allOrderInfo);
        return pageInfo;
    }

    @Override
    public List<AwaitingShipment> getAwaitingShipmentOrderInfoByState() {
        return orderInfoMapper.getAwaitingShipmentOrderInfoByState();
    }

    @Override
    public List<AwaitingShipment> getAwaitingPaymentOrderInfoByState() {
        return orderInfoMapper.getAwaitingPaymentOrderInfoByState();
    }

    @Override
    public List<AwaitingShipment> getAllOrderInfoByState() {
        return orderInfoMapper.getAllOrderInfoByState();
    }

    @Override
    public Integer updateDeliveryAddress(String delivery_address, Integer order_id) {
        Integer i= orderInfoMapper.updateDeliveryAddress(delivery_address,order_id);
        return i;
    }

    @Override
    public Integer deleteOrderInfo(Integer order_id) {
        return orderInfoMapper.deleteOrderInfo(order_id);
    }


    @Override
    public List<AwaitingShipment> getRoadingShipmentOrderInfoByState() {
        return orderInfoMapper.getRoadingShipmentOrderInfoByState();
    }

    @Override
    public List<AwaitingShipment> getFinishingShipmentOrderInfoByState() {
        return orderInfoMapper.getFinishingShipmentOrderInfoByState();
    }

    @Override
    public Integer updateOrderState(String order_state, Integer order_id) {
        return orderInfoMapper.updateOrderState(order_state,order_id);
    }

    @Override
    public Double getMoneyByDay(Date date) {
        return orderInfoMapper.getMoneyByDay(date);
    }

}